/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package genomemap.cef.command.listener;

import cef.command.listener.CommandOutputListener;
import cef.command.listener.DescribeObjectPrintWriter;
import genomemap.data.KSA00Data;
import genomemap.data.OrganismData;
import genomemap.data.OrganismDataUtil;
import genomemap.data.TAB08Data;

import java.io.PrintWriter;

/**
 *
 *
 * @version 1.3.0
 * @author Susanta Tewari
 * @history Created on 2/6/13
 * @since 1.3.0
 */
public class DescribeObject_PW_s {

    /**
     * @version 1.3.0
     * @since 1.3.0
     * @history Created on 02/09/2013
     * @author Susanta Tewari
     */
    public static class KSA00DataPW extends DescribeObjectPrintWriter<KSA00Data> {

        @Override
        public void describe(final PrintWriter printWriter, final KSA00Data object) {

            printWriter.println(object);
            printWriter.flush();
        }

        @Override
        public CommandOutputListener newInstance() {
            return new KSA00DataPW();
        }
    }

    /**
     * @version 1.3.0
     * @since 1.3.0
     * @history Created on 02/06/2013
     * @author Susanta Tewari
     */
    public static class OrganismDataPW extends DescribeObjectPrintWriter<OrganismData> {

        @Override
        public void describe(final PrintWriter printWriter, final OrganismData object) {

            printWriter.println("Linkage Groups: " + object.getLinkageGroups());

            final int probe_count         = OrganismDataUtil.countProbes(object);
            final int hybrid_count        = OrganismDataUtil.countSignal(object);
            final double avg_hybrid_count = (double) hybrid_count / probe_count;
            final int genome_length       = OrganismDataUtil.genomeLength(object);
            final double map_resolution   = (double) genome_length / (2 * probe_count);

            printWriter.println("Genome Probe count: " + probe_count);
            printWriter.println("Genome Hybridization count: " + hybrid_count);
            printWriter.println("Genome Average Hybridization count: " + avg_hybrid_count);
            printWriter.println("Genome Length: " + genome_length);
            printWriter.println("Genome Map Resolution: " + map_resolution);
            printWriter.flush();
        }

        @Override
        public CommandOutputListener newInstance() {
            return new OrganismDataPW();
        }
    }

    /**
     * @version 1.3.0
     * @since 1.3.0
     * @history Created on 02/09/2013
     * @author Susanta Tewari
     */
    public static class TAB08DataPW extends DescribeObjectPrintWriter<TAB08Data> {

        @Override
        public void describe(final PrintWriter printWriter, final TAB08Data object) {

            printWriter.println(object);
            printWriter.flush();
        }

        @Override
        public CommandOutputListener newInstance() {
            return new TAB08DataPW();
        }
    }
}
